package cn.edu.xmu.restfuldemo.model.VO;

import cn.edu.xmu.restfuldemo.model.BO.GoodsSku;
import cn.edu.xmu.restfuldemo.model.BO.OrderItem;
import cn.edu.xmu.restfuldemo.model.BO.Orders;
import cn.edu.xmu.restfuldemo.model.VoObject;
import io.swagger.annotations.ApiModel;
import lombok.*;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @author Zijun Min
 * @description
 * @createTime 2021/10/22 17:04
 **/
@Data
@ApiModel(description = "orders+orderitems+goodsSku返回类型")
@Getter
@Setter
@AllArgsConstructor
@ToString
public class OrderWithItemsSkuRetVo implements VoObject {
    private Long id;
    private String orderSn;
    private Long pid;
    private Byte orderType;
    private Byte state;
    private Byte subState;
    private Long originPrice;
    private Long discountPrice;
    private Long freightPrice;
    private Integer rebateNum;
    private String message;
    private Long regionId;
    private String address;
    private String mobile;
    private String consignee;
    private Long couponId;
    private Long grouponId;
    private Long presaleId;
    private String shipmentSn;
    private LocalDateTime confirmTime;
    private LocalDateTime gmtCreate;
    private LocalDateTime gmtModified;
    private List<OrderItemRetVo> orderItemRetVos;
    private List<GoodsSkuRetVo> goodsSkuRetVos;

    public OrderWithItemsSkuRetVo(){
        orderItemRetVos = new ArrayList<>();
        goodsSkuRetVos =new ArrayList<>();
    }

    public OrderWithItemsSkuRetVo(Orders orders, List<OrderItem>orderItems,List<GoodsSku>goodsSkus) {
        this.id = orders.getId();
        this.orderSn = orders.getOrderSn();
        this.pid = orders.getPid();
        this.orderType = orders.getOrderType();
        this.state = orders.getState();
        this.subState = orders.getSubstate();
        this.originPrice = orders.getOriginPrice();
        this.discountPrice = orders.getDiscountPrice();
        this.freightPrice = orders.getId();
        this.rebateNum = orders.getRebateNum();
        this.message = orders.getMessage();
        this.regionId = orders.getRegionId();
        this.address = orders.getAddress();
        this.mobile = orders.getMobile();
        this.consignee = orders.getConsignee();
        this.couponId = orders.getCouponId();
        this.grouponId = orders.getGrouponId();
        this.presaleId = orders.getPresaleId();
        this.shipmentSn = orders.getShipmentSn();
        this.confirmTime = orders.getConfirmTime();
        this.gmtCreate = orders.getGmtCreate();
        this.gmtModified = orders.getGmtModified();
        List<OrderItemRetVo>orderItemRetVos = new ArrayList<>();
        for(OrderItem orderItem:orderItems){
            orderItemRetVos.add(new OrderItemRetVo(orderItem));
        }
        this.orderItemRetVos = orderItemRetVos;
        List<GoodsSkuRetVo>goodsSkuRetVos = new ArrayList<>();
        for(GoodsSku goodsSku:goodsSkus){
            goodsSkuRetVos.add(new GoodsSkuRetVo(goodsSku));
        }
        this.goodsSkuRetVos = goodsSkuRetVos;
    }

    public List<OrderItem> newOrderItemList(){
        if(this.orderItemRetVos==null){
            this.orderItemRetVos = new ArrayList<>();
        }
        List<OrderItem>orderItems = new ArrayList<>();
        for(OrderItemRetVo orderItemRetVo:this.orderItemRetVos){

        }
        return orderItems;
    }

    public List<GoodsSku> newGoodsSkuList(){
        if(this.goodsSkuRetVos==null){
            this.goodsSkuRetVos = new ArrayList<>();
        }
        List<GoodsSku>goodsSkus = new ArrayList<>();
        for(GoodsSkuRetVo goodsSkuRetVo:this.goodsSkuRetVos){

        }
        return goodsSkus;
    }


    @Override
    public Object createVo() {
        return this;
    }

    @Override
    public Object createSimpleVo() {
        return this;
    }
}
